package com.yulan.bankback.mapper.bank;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yulan.bankback.entity.model.bank.UserMsg;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface UserMsgMapper extends BaseMapper<UserMsg> {

    @Select("select msg_id, src_uid, dest_uid, msg, msg_date, type " +
            "from user_msg " +
            "where msg_id in (select msg_id from user_msg where dest_uid = #{uid} or src_uid = #{uid})" +
            "and type != 'system-msg' " +
            "order by msg_date")
    List<UserMsg> getAllChat(@Param("uid") String uid);

}
